package sort;
/**
 * @description: 冒泡排序
 * @author: walt-zhong
 * @createDate: 2021/3/5
 */
public class Bubble {

    public Bubble(){}
    public  boolean greater(Comparable a, Comparable b){
        return a.compareTo(b)>0;
    }

    public  void swap(Comparable []arr,int i,int j){
        Comparable temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }

    public void sort(Comparable[] arr){
        for (int i = arr.length-1;i>0;i--) {
            for(int j = 0;j<i;j++){
                if(greater(arr[i],arr[j])){
                    swap(arr,i,j);
                }
            }
        }



    }
}
